package com.dao;

import com.pojo.AccountRole;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author mornd
 * @date 2020/11/30 - 10:08
 */
public interface AccountRoleDao {

    /**
     * 估计account的id查询对应的role集合
     *
     * @param accountId
     * @return
     */
    @Select("SELECT * FROM t_accountrole WHERE id IN(SELECT roleId FROM t_account_role WHERE accountId = #{accountId})")
    List<AccountRole> findRoleListByAccountId(Integer accountId);

    /**
     * 添加默认为user的角色
     *
     * @param accountId
     * @return
     */
    @Insert("insert into t_account_role(accountId,roleId) values(#{accountId},2)")
    int addDefaultRoleByAccount(Integer accountId);
}
